package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Role;
import cn.wolfcode.mapper.RoleMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IRoleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements IRoleService {

    @Autowired
    private RoleMapper roleMapper;


    @Override
    public List<Role> selectAll() {
        return roleMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(Role role) {
        roleMapper.updateByPrimaryKey(role);
    }

    @Override
    public void insert(Role role) {
        roleMapper.insert(role);
    }

    @Override
    public PageInfo<Role> que(QueryObject queryObject) {
        PageHelper.startPage(queryObject.getCurrentPage(),queryObject.getPageSize());
        List<Role> list=roleMapper.selectLimit(queryObject);
        return new PageInfo<>(list);
    }

    @Override
    public Role selectByPrimaryKey(Long id) {
        return roleMapper.selectByPrimaryKey(id);
    }

    @Override
    public void insertById(Long id, Long ids) {
        roleMapper.insertByIds(id,ids);
    }

    @Override
    public void deleteByPrimaryKey(Long id) {
        roleMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void deleteByRoleid(Long id) {
        roleMapper.deleteByRoleId(id);
    }

    @Override
    public List selectByEmid(Long id) {
        return  roleMapper.selectByEmid(id);
    }


}
